package andpig.rola;

import java.util.Vector;

import android.app.Activity;
import android.content.ContentResolver;
import android.content.res.Configuration;
import android.os.Bundle;
import android.provider.Settings.System;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.GridView;

public class andpig extends Activity implements OnClickListener{
    /** Called when the activity is first created. */
	/*String[] ListItems = new String[]{"Name1", "Wert1", 
										"Name2", "Wert2", 
										"Name3", "Wert3",
										"Name4", "Wert4",
										"Name5", "Wert5",
										"Name6", "Wert6",
										"Name7", "Wert7",
										"Name8", "Wert8",
										"Name9", "Wert9",
										"Name10", "Wert10",
										"Name11", "Wert11"
	};*/
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        //this.fillList(ListItems);

        Button bE = (Button) findViewById(R.id.ButtonExit);
        bE.setOnClickListener(this);
        Button bI = (Button) findViewById(R.id.ButtonInfo);
        bI.setOnClickListener(this);
    }
    
    
	/**
	 * @param listItems
	 */
	private void fillList(String[] listItems)
	{
		// TODO Auto-generated method stub
		GridView gridview = (GridView) findViewById(R.id.gridview);
        gridview.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listItems));
	}

	/* (non-Javadoc)
	 * @see android.view.View.OnClickListener#onClick(android.view.View)
	 */
	public void onClick(View v)
	{
		if(v.getId() == R.id.ButtonExit)
		{
			this.finish();
		}
		else if(v.getId() == R.id.ButtonInfo)
		{
			this.fillList(this.getPhoneInformation());
			//this.getPhoneInformation();
		}
	}

	/**
	 * @return
	 */
	private String[] getPhoneInformation()
	{
		String[] List = new String[12];
		
		ContentResolver cr = this.getContentResolver();
		Configuration con = new Configuration();
		
		System.getConfiguration(cr, con);
		
		List[0] = "Font Scale";
		List[1] = ((Float)con.fontScale).toString();
		List[2] = "Hard Keyboard hidden";
		if(con.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO)
			List[3] = "no";
		else if (con.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES)
			List[3] = "yes";
		else
			List[3] = "undefined";
		List[4] = "Keyboard Layout";
		if(con.keyboard == Configuration.KEYBOARD_QWERTY)
			List[5] = "QWERTY";
		else if(con.keyboard == Configuration.KEYBOARD_12KEY)
			List[5] = "12 Keys";
		else if(con.keyboard == Configuration.KEYBOARD_NOKEYS)
			List[5] = "no Keys";
		else
			List[5] = "undefined";
		List[6] = "Locale";
		List[7] = con.locale.toString();
		List[8] = "Mobile Country Code";
		List[9] = ((Integer)con.mcc).toString();
		List[10] = "Mobile Network Code";
		List[11] = ((Integer)con.mnc).toString();
		
		return List;
	}
}